<?php
/**
 * Created by JetBrains PhpStorm.
 * User: GMC
 * Date: 10/3/13
 * Time: 2:20 PM
 * To change this template use File | Settings | File Templates.
 */

class WidgetUserProducts extends CWidget {
    public $products, $user_id, $product_id;

    public function init() {

        $products = Product::model()->findAll(array(
            'select' => 'product_id, product_name, image_id, price, currency, location,user_id, user_name',
            'condition' => 'user_id = :user_id and product_id != :product_id and (published  = 1 or status = 1)',
            'order' => 'product_id desc',
            'limit' => 5,
            'params' => array(':user_id' => $this->user_id, ':product_id' => $this->product_id)
        ));
        $this->products = $products;
    }

    public function run() {
        return CWidget::render('widgetUserProducts', array('model' => $this->products));
    }
}